<!DOCTYPE html>
<html>
<head>
    <title>文件管理
</title>
		<#include "/header.html">
</head>
<body>
<!--<div id="rrapp" v-cloak>-->
<!--    <div v-show="showList">-->
<!--        <div class="grid-btn">-->
<!--			<#if shiro.hasPermission("file:file:save")>-->
<!--            <a class="btn btn-primary" @click="add"><i class="fa fa-plus"></i>&nbsp;新增</a>-->
<!--			</#if>-->
<!--			<#if shiro.hasPermission("file:file:update")>-->
<!--            <a class="btn btn-primary" @click="update"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</a>-->
<!--			</#if>-->
<!--			<#if shiro.hasPermission("file:file:delete")>-->
<!--            <a class="btn btn-primary" @click="del"><i class="fa fa-trash-o"></i>&nbsp;删除</a>-->
<!--			</#if>-->
<!--        </div>-->
<!--        <table id="jqGrid"></table>-->
<!--        <div id="jqGridPager"></div>-->
<!--    </div>-->

<!--    <div v-show="!showList" class="panel panel-default">-->
<!--        <div class="panel-heading">{{title}}</div>-->
<!--        <form class="form-horizontal">-->
<!--														                    <div class="form-group">-->
<!--                        <div class="col-sm-2 control-label">文件名称</div>-->
<!--                        <div class="col-sm-10">-->
<!--                            <input type="text" class="form-control" v-model="file.fileName" placeholder="文件名称"/>-->
<!--                        </div>-->
<!--                    </div>-->
<!--											                    <div class="form-group">-->
<!--                        <div class="col-sm-2 control-label">创建时间</div>-->
<!--                        <div class="col-sm-10">-->
<!--                            <input type="text" class="form-control" v-model="file.creatTime" placeholder="创建时间"/>-->
<!--                        </div>-->
<!--                    </div>-->
<!--											                    <div class="form-group">-->
<!--                        <div class="col-sm-2 control-label">创建人id</div>-->
<!--                        <div class="col-sm-10">-->
<!--                            <input type="text" class="form-control" v-model="file.creatUserId" placeholder="创建人id"/>-->
<!--                        </div>-->
<!--                    </div>-->
<!--											                    <div class="form-group">-->
<!--                        <div class="col-sm-2 control-label">文件大小（字节）</div>-->
<!--                        <div class="col-sm-10">-->
<!--                            <input type="text" class="form-control" v-model="file.size" placeholder="文件大小（字节）"/>-->
<!--                        </div>-->
<!--                    </div>-->
<!--											                    <div class="form-group">-->
<!--                        <div class="col-sm-2 control-label">文件类型</div>-->
<!--                        <div class="col-sm-10">-->
<!--                            <input type="text" class="form-control" v-model="file.type" placeholder="文件类型"/>-->
<!--                        </div>-->
<!--                    </div>-->
<!--							            <div class="form-group">-->
<!--                <div class="col-sm-2 control-label"></div>-->
<!--                <input type="button" class="btn btn-primary" id="btnSaveOrUpdate" data-loading-text="保存中..." @click="saveOrUpdate" value="确定"/>-->
<!--                &nbsp;&nbsp;<input type="button" class="btn btn-warning" @click="reload" value="返回"/>-->
<!--            </div>-->
<!--        </form>-->
<!--    </div>-->
<!--</div>-->

<!-- 选择菜单 -->

<div class="zTreeDemoBackground left" style="display: none;padding:10px;">
	<div style="width: 100%; margin-bottom: 25px; display: block;">
		<div class="form-group col-sm-2" style="padding: 0!important;">
			<input type="text" placeholder="文件名称" class="form-control" id="key">
		</div>
		<#if shiro.hasPermission("file:file:downloadFolder")>
		<a class="btn btn-default" style="margin-left: 10px;" onclick="xiazai()">下载</a>
	    </#if>
    	<#if shiro.hasPermission("file:file:deleteFile")>
	    <a class="btn btn-default" style="margin-left: 10px;" onclick="deleteFile()">删除</a>
        </#if>
        <a class="btn btn-default" style="margin-left: 10px;visibility: hidden" >删除</a>
	</div>
    <div> <ul id="treeDemo" class="ztree"></ul></div>

</div>
<a id="saves1" style="display: none;"></a>

<!--<li><p>搜索试试看：<br/>-->
<!--	关键字：<input type="text" id="key1" value="" class="empty" placeholder="请输入关键字"/><br/>-->
<!--</p>-->
<!--</li>-->

<!--<script src="${request.contextPath}/statics/plugins/ztree/jquery.ztree.all.min.js"></script>	-->
<!--<script src="${request.contextPath}/statics/plugins/ztree/jquery.ztree.exedit.js"></script>-->
<!--<script src="${request.contextPath}/statics/plugins/ztree/fuzzysearch.js"></script>-->
<!--<script src="${request.contextPath}/statics/plugins/ztree/jquery.ztree.exhide.js"></script>-->

<script type="text/javascript" src="${request.contextPath}/statics/plugins/ztree1/jquery.ztree.core.js"></script>
<script type="text/javascript" src="${request.contextPath}/statics/plugins/ztree1/jquery.ztree.exhide.js"></script>


<script type="text/javascript" src="${request.contextPath}/statics/plugins/ztree1/fuzzysearch.js"></script>
<script type="application/javascript">
	var trees;
//  var setting = {};
    var setting = {
    			view: {
					nameIsHTML: true, //允许name支持html				
					selectedMulti: false
				},
			edit: {
				enable: false
			},
			data: {
				simpleData: {
					enable: false
				}
			},
			callback: {
				beforeRemove: beforeRemove,
				onClick:onCheck
			}
		};
    $.ajax({
        type: "GET",
        url: "/file/file/list",
        success: function(data){
            $.fn.zTree.init($("#treeDemo"), setting, data.data);
            var zTree = $.fn.zTree.getZTreeObj("treeDemo")
			console.log(zTree)            
			fuzzySearch('treeDemo','#key',null,true);
            console.log(trees)
            $(".zTreeDemoBackground").show();
            
        }	
    });
    function ajaxs(){
    	$.ajax({
        type: "GET",
        url: "/file/file/list",
        success: function(data){
            $.fn.zTree.init($("#treeDemo"), setting, data.data);
            var zTree = $.fn.zTree.getZTreeObj("treeDemo")
			console.log(zTree)            
			fuzzySearch('treeDemo','#key',null,true);

            console.log(trees)
            $(".zTreeDemoBackground").show();
            
        }	
    });
    }
    // /file/file/deleteFile?path=""
    function beforeRemove(treeId, treeNode) {
    	console.log(treeId)
    	console.log(treeNode)
    }
    var nodes,nodeId,nodeIds
    function onCheck(e,treeId,treeNode){
	            var treeObj=$.fn.zTree.getZTreeObj("treeDemo"),
	            nodes=treeObj.getSelectedNodes();
	            console.log(nodes)
	            nodeId=nodes[0].url;
	            nodeIds=nodes.url;
	            var a = 0;
	           for(var i = 0; i < nodeId.length; i++){
	           		if(nodeId[i] == '?'){
		    			a = i;
		    		}
	           }
	          
		    	nodeIds = nodeId.substring(a,nodeId.length)
		    	console.log(nodeIds)
	}
    function deleteFile(){
		var lock = false;
		layer.confirm('确定要删除选中的文件', {
			btn: ['确定','取消'] //按钮
		}, function(){
			if(!lock) {
				lock = true;
				$.ajax({
					type: "GET",
					url: "/file/file/deleteFile"+nodeIds,
					success: function(data){
						layer.msg("操作成功", {icon: 1});
						ajaxs()
					}
				});
			}
		}, function(){
		});


    }
	function xiazai(){
		window.open(nodeId)
	}
	


</script>

<script src="${request.contextPath}/statics/js/modules/file/file.js?_${.now?long}"></script>
</body>
</html>